#!/bin/bash

echo "==================================="
echo " Starting Blog in PRODUCTION Mode"
echo "==================================="
echo

set -e

echo "[1/2] Building Frontend Application..."
npm run build --prefix frontend
echo "Frontend build completed successfully."
echo

echo "[2/2] Starting Production Server..."
export NODE_ENV=production
npm start --prefix backend

echo
echo "==================================="
echo "  Blog is running in PRODUCTION mode."
echo "  Access it at http://localhost:3001"
echo "==================================="